﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLT_Public;
using System.Data;

namespace QLT_Data
{
   public  class KhachHang_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_tbl_KhachHang");
       }
       public DataTable Load_TimKiem_KhachHang()
       {
           return kn.LayDuLieu("Load_TimKiem_KhachHang");
       }
       public DataTable TimKiem_TenKH(KhachHang_Public tenKH)
       {
           int n = 1;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@TenKH";
           value[0] = tenKH.TenKH;
           return kn.LayDuLieu("TimKiem_TenKH", name, value, n);
       }
       public DataTable TimKiem_DiaChi(KhachHang_Public diaChi)
       {
           int n = 1;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@DiaChi";
           value[0] = diaChi.DiaChi;
           return kn.LayDuLieu("TimKiem_DiaChi", name, value, n);
       }
       public DataTable TimKiem_TenKH_DiaChi(KhachHang_Public tenKH, KhachHang_Public diaChi)
       {
           int n = 2;
           string[] name = new string[n];
           object[] value = new object[n];
           name[0] = "@TenKH";
           value[0] = tenKH.TenKH;
           name[1] = "@DiaChi";
           value[1] = diaChi.DiaChi;
           return kn.LayDuLieu("TimKiem_TenKH_DiaChi", name, value, n);
       }
       public DataTable TaoBang(string sql)
       {
           return kn.taoBang(sql);
       }
       public int Insert_KhachHang(KhachHang_Public tenKH, KhachHang_Public diaChi)
       {
           int Nparameter = 2;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@TenKH";
           value[0] = tenKH.TenKH;
           name[1] = "@DiaChi";
           value[1] = diaChi.DiaChi;
           return kn.update("insert_KhachHang", name, value, Nparameter);
       }
       public int Update_KhachHang(KhachHang_Public maKH, KhachHang_Public tenKH, KhachHang_Public diaChi)
       {
           int Nparameter = 3;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaKH";
           value[0] = maKH.MaKH;
           name[1] = "@TenKH";
           value[1] = tenKH.TenKH;
           name[2] = "@DiaChi";
           value[2] = diaChi.DiaChi;
           return kn.update("update_KhachHang", name, value, Nparameter);
       }
       public int Delete_KhachHang(KhachHang_Public maKH)
       {
           int Nparameter = 1;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaKH";
           value[0] = maKH.MaKH;
           return kn.update("delete_KhachHang", name, value, Nparameter);
       }
    }
}
